home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7451 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: gwen.pcug.co.uk!altheim!broldham
  2. Newsgroups: comp.lang.c
  3. Message-ID: <1168@altheim.win-uk.net>
  4. References: <1996Feb21.101532.15110@es.dupont.com> <1996Feb21.174407.20730@newshost.micro.ti.com><4ghq1u$sed@hpbblb.bbn.hp.com>
  5. Reply-To: broldham@altheim.win-uk.net (Brian R. Oldham)
  6. From: broldham@altheim.win-uk.net (Brian R. Oldham)
  7. Date: Mon, 26 Feb 1996 12:32:47 GMT
  8. Subject: Re: String Encryption
  9.  
  10.  
  11. In article <4ghq1u$sed@hpbblb.bbn.hp.com>, Matthias Dittrich (matti) writes:
  12. >brett@racerx.micro.ti.com (Brett L. Huber) wrote:
  13. >>Malcolm Smart (MALCOLM.SMART@CONOCO.DUPONT.COM) wrote:
  14. >>> Has anybody out there got any small routines that I can apply to strings 
  15. >>> which will effectively encrypt them (and decrypt!).  It's not a matter of 
  16. >>> state security so it doesn't have to be that secure, just make it 
  17. >>> unreadable.  
  18. >>
  19. >>It really depends on what level of "unreadability" you want.  Who are
  20. >>you protecting the data from?  If you aren't protecting a secret, try
  21. >>"rot13," which translates A->N, B->O, ... Z->M.
  22. >>
  23. >>For an introduction to cryptographic techniques, try the sci.crypt FAQ:
  24. >>http://www.cis.ohio-state.edu/hypertext/faq/bngusenet/sci/crypt/top.html
  25. >>
  26. >> ...
  27. >You also can use the crypt() function (see man 3 crypt).
  28. >
  29. >Good luck,
  30. >Matthias
  31. >
  32. Thanks for this information. But for those who like me have only
  33. mail & news (no web access) it is helpful to find information here.
  34.  
  35. To comply with Malcolm's caveat, that the encryption routine should
  36. be a simple one I have found this effective:
  37.  
  38. for(i=0; i<strlen(buffer); i++)
  39.     str[i] = ~buffer[i];     /* note the ~ operator */
  40.  
  41. The ~ operator flips all bits in each byte read rendering the text in
  42. str unreadable.  Use the same operation to reverse it. 
  43.  
  44.  
  45. ---
  46. Brian Oldham
  47. Hucknall UK
  48. !...Gesundbrunnen
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.